<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <#include "../../common/header.ftl">
</head>
<body>
<input type="hidden" value="${companyId}" id="companyId">
<div class="container-fluid">
    <#include "../../common/left-nav.ftl">

    <div class="main-box">
        <ol class="breadcrumb crumbs">
            <li><a href="${base}/admin/company">企业管理</a></li>
            <li class="active">详情</li>
        </ol>

        <div class="caption">
            <h2 data-field="unitName">-</h2>
            <div class="ctrl-box">
                <a href="${base}/admin/company/edit?id=${companyId}" type="button"
                   class="btn btn-primary btn-sm">
                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                </a>

                <button type="button" class="btn btn-danger btn-sm" onclick="removeData(${companyId})">
                    <span class="glyphicon glyphicon-trash"></span> 删除
                </button>
            </div>
        </div>

        <div class="container-fluid">
            <div class="panel panel-info panel-freight">
                <div class="panel-heading"><b>基础信息</b></div>
                <div class="panel-body">
                    <div class="details-panel">
                        <div class="item">
                            <span class="field">单位名称</span>
                            <span class="value" data-field="unitName">-</span>
                        </div>

                        <div class="item">
                            <span class="field">税号</span>
                            <span class="value" data-field="taxNo">-</span>
                        </div>

                        <div class="item">
                            <span class="field">注册资金</span>
                            <span class="value" data-field="registeredCapital">-</span>
                        </div>

                        <div class="item">
                            <span class="field">注册地</span>
                            <span class="value" data-field="registration">-</span>
                        </div>

                        <div class="item">
                            <span class="field">主营业务</span>
                            <span class="value" data-field="business">-</span>
                        </div>

                        <div class="item">
                            <span class="field">自有车队规模</span>
                            <span class="value" data-field="scale">-</span>
                        </div>

                        <div class="item">
                            <span class="field">主营线路</span>
                            <span class="value" data-field="mainLine">-</span>
                        </div>
                    </div>
                </div>
            </div>

            <div class="panel panel-info panel-freight">
                <div class="panel-heading"><b>联系信息</b></div>
                <div class="panel-body">
                    <div class="details-panel">
                        <div class="item">
                            <span class="field">管理账号</span>
                            <span class="value" data-field="username">-</span>
                        </div>

                        <div class="item">
                            <span class="field">联系人</span>
                            <span class="value" data-field="contact">-</span>
                        </div>

                        <div class="item">
                            <span class="field">联系电话</span>
                            <span class="value" data-field="tel">-</span>
                        </div>

                        <div class="item">
                            <span class="field">企业地址</span>
                            <span class="value" data-field="address">-</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script type="text/javascript">
    var companyId = $('#companyId').val();
    $(document).ready(function () {
        $.httpclient.get(API_COMPANY + '/' + companyId, {
            time: new Date().getTime()
        }, function (data) {
            data = data.obj;
            for (var key in data) {
                var item = $('[data-field="' + key + '"]');
                if (item) {
                    var target = item.data('field-target');
                    var value = data[key];
                    if (target === 'img' && value) {
                        item.attr('src', $('#base').val() + '/file/image/' + value);
                    } else {
                        item.text(data[key]);
                    }

                }
            }
        })
    })

    function removeData(id) {
        bootbox.confirm({
            size: "small",
            message: '是否删除该企业信息?',
            buttons: {
                confirm: {
                    label: '是',
                    className: 'btn-danger'
                },
                cancel: {
                    label: '否',
                    className: 'btn-success'
                }
            },
            callback: function (result) {
                if (result) {
                    $.httpclient.delete(API_COMPANY + "/" + id, {
                        time: new Date().getTime()
                    }, function () {
                        location.href = ctx + '/admin/company';
                    });
                }
            }
        });
    }
</script>